<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" name="" id="ipt">
 <script>
    const reg=/^\d{6}$/
    const inputValue=document.querySelector('#ipt')
    inputValue.addEventListener('change',function(){
        if(reg.test(inputValue.value)){
    console.log('输入正确！');
   }else{
    console.log('请输入6位数字');
   }
    })
   
 </script>
</body>
</html>